package com.daJiao.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * <p>Title:      AuditStatusConverter. </p>
 * <p>Description 审核状态 </p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company:    医百科技有限公司 </p>
 *
 * @author         <a href="yangwensheng@100doc.com.cn"/>杨文生</a>
 * @since      2021/3/18 14:11
 */
public class AuditStatusConverter implements Converter<Integer> {

    @Override
    public Class<Integer> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(ReadCellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public WriteCellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
                                                    GlobalConfiguration globalConfiguration) {
        return new WriteCellData<>(getStatusDesc(value));
    }

    private String getStatusDesc(Integer status) {
        String statusDesc = "未审核";
       if(status.equals(0)){
           statusDesc = "未审核";
       }else if(status.equals(1)){
           statusDesc = "审核通过";
       } else if(status.equals(2)){
           statusDesc = "未通过";
       }else if(status.equals(3)){
           statusDesc = "暂停使用";
       }
       return statusDesc;
    }

}
